‹#›
Autodesk Inventor 定制开发在线培训 2010
•Inventor 2008 和更老的版本：
§当引用 COM 库时，会自动创建 Interop 程序集
§可以手动创建 Interop 程序集 :
§tlbimp rxinventor.tlb /out:c:\MyAddIn\myversionof.interop.inventor.dll /primary [/keyfile:c:\MyAddIn\mykey.snk /namespace:Inventor]
•
•Inventor 2009 以及更新版本：
§一个强名的 interop 程序集随产品默认安装并保存在 GAC (Global Assembly Cache)
•Interop Assembly

| Interop assembly is needed to interact from .NET with the Inventor COM library.
| In case of Inventor 2008 and previous releases you needed to reference the COM library in your .NET project and Visual Studio created the interop assembly for you.
| You could also create the interop assembly manually or in case you needed to create a string named AddIn, then the interop assembly needed to be string named as well, and therefore you had to create the interop assembly yourself providing a strong neme key.
| In case of Inventor 2009 the strong named interop assembly is part of the Inventor installation and is placed in the GAC, you can just reference it as any other Microsoft .NET assemblies.
| If you want to make your AddIn compatible with 2008 and 2009 as well (and is not dependent on any Inventor 2009 specific feature), then you would need to reuse the assembly created for your Inventor 2008 AddIn.
| Using .Net with Inventor's API
| From Inventor 2009, a Primary Interop Assembly (PIA) is supplied. This provides the .Net compatible interface to Inventor's API. The .Net languages require a .Net compatible programming interface but Inventor's API is a COM Automation interface. An Interop assembly provides a .Net compatible interface to a COM Automation API. In all previous versions of Inventor you had to create your own interop assembly. Visual Studio does this automatically whenever you reference a COM type library. The fact that every .Net program had its own interop assembly resulted in additional memory being consumed, and because of the way .Net resolves these assemblies, unexpected behavior could have also resulted in some cases.
| A primary interop is one created by Autodesk and delivered for all clients to use. The PIA is delivered into the Global Assembly Cache (GAC) where everyone has access to it. All clients that are writing code using any of the .Net languages should now use this primary interop assembly.
| Although the PIA is delivered into the GAC when Inventor is installed, it is only usable by existing applications. .Net does not allow you to directly reference the PIA that is in the GAC but requires you to select a PIA outside of the GAC. This will still result in using the PIA in the GAC. The external version of Inventor's PIA is delivered as part of the new Developer Tools install in the SDK. Once you've installed the DeveloperTools.msi you'll see "Autodesk.Inventor.Interop" in the .Net tab of the "Add Reference" dialog within Visual Studio.
| There are some differences between the PIA and the interop assembly automatically generated when referencing the Inventor type library. The difference provides for more correct type information in the PIA. The primary change is that instead of arrays being declared as generic System.Array types, they are now type specific, i.e. Double(). This change will require edits to your code, but they're easily corrected, and appropriate messages will appear at compile time.